package mapper

import (
	"github.com/beego/beego/v2/client/orm"
	"ksd-social-api/modules/special/model"
)

type SpecialCategoryMapper struct{}

/**
 * 查找专题分类
 * @author feige
 * @date 2023-11-03
 * @version 1.0
 * @desc
 */
func (mapper *SpecialCategoryMapper) FindCategories(systemId uint64) ([]model.SpecialCategory, error) {
	// 获取数据库链接
	mysql := orm.NewOrm()
	// 准备一个切片容器
	var categorys []model.SpecialCategory
	// 执行查询
	_, err := mysql.Raw("select id,title,icon,parent_id from xk_special_category where  status = 1 and is_deleted = 0 and system_id = ? order by sorted ").SetArgs(systemId).QueryRows(&categorys)
	if err != nil {
		return nil, err
	}
	return categorys, nil
}
